/*
 * Things to highlight in the example:
 * 1. param name "i" is different when it is in fractorial(i) and fact(i)
 * 2. nested function fact is only visible to fractorial(), its parent
 */

package helloscala.practise.chapter2

object FractorialUtil {
  def fractorial(i: Int): Int = {
    def fact(i: Int, accumulator: Int): Int = {
      if (i <= 1)
        accumulator
      else
        fact(i - 1, i * accumulator)
    }

    fact(i, 1)
  }
}
